//对axios二次封装
import axios from 'axios'
import nprogress from 'nprogress'

import 'nprogress/nprogress.css'

const requests = axios.create({
  baseURL: '/mock',
  timeout: 5000//响应时间
})
//请求拦截器
requests.interceptors.request.use(config => {
  nprogress.start() //进度条开始
  return config
})

//响应拦截器
requests.interceptors.response.use(res => {
  nprogress.done()//进度条结束
  return res.data
}, err => Promise.reject(new Error('fail' + err)))

export default requests;